import request from '@/utils/request'

// 查询列表接口
export const getSnacksPage = (params) => {
  return request({
    url: '/snacks/page',
    method: 'get',
    params
  })
}

// 文件down预览
export const commonDownload = (params) => {
  return request({
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    },
    url: '/common/download',
    method: 'get',
    params
  })
}


// 新增接口
export const addSnacks = (params) => {
  return request({
    url: '/snacks',
    method: 'post',
    data: { ...params }
  })
}

//修改 --- 零食停售起售状态
export const snacksStatusByStatus = (params) => {
  return request({
    url: `/snacks/status/${params.status}`,
    method: 'get',
    params: { id: params.id }
  })
}

//根据id查询零食详情
export const querySnacksById = (id) =>{
  return request({
    url:`/snacks/${id}`,
    method: 'GET'
  }) 
}

// 修改接口
export const editSnacks = (params) => {
  return request({
    url: '/snacks',
    method: 'put',
    data: { ...params }
  })
}

// 删除接口
export const deleteSnacks = (ids) => {
  return request({
    url: '/snacks',
    method: 'delete',
    params: { ids }
  })
}

// 获取零食分类列表()
export const getCategoryList = (params) => {
  return request({
    url: '/category/list',
    method: 'get',
    params
  })
}

// 查通过零食分类id查零食的接口
export const querySnacksList = (params) => {
  return request({
    url: '/snacks/list',
    method: 'get',
    params
  })
}